package com.example.managesystem.mapper;

import com.example.managesystem.dto.FileDTO;
import com.example.managesystem.dto.TypeDownloadFileDTO;
import com.example.managesystem.entity.File;
import com.example.managesystem.vo.FileMainVO;
import com.example.managesystem.vo.FileMainsVO;
import com.example.managesystem.vo.FileVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FileMapper {
    @Insert("insert into file (file_name,item_id,item_name,file_url,create_time,over_time,format) values(#{fileName},#{itemId},#{ItemName},#{fileUrl},#{createTime},#{overTime},#{format})")
    void saveFile(FileDTO fileDTO);

    /**
     * 根据文件id查询文件
     */
    @Select("select * from file where file_id = #{fileId}")
    File getFileByFileId(Integer fileId);

    /**
     * 根据条件查询文件
     */
    @Select("select file_id,file_name,file_url from file where item_id = #{typeDownloadFileDTO.itemId} and item_name = #{typeDownloadFileDTO.itemName} and create_time > #{typeDownloadFileDTO.createTime} and over_time < #{typeDownloadFileDTO.overTime} and format = #{typeDownloadFileDTO.format}")
    List<FileMainVO> queryByDTO(@Param("typeDownloadFileDTO") TypeDownloadFileDTO typeDownloadFileDTO);

    /**
     * 根据文件id查询文件
     * @param i
     * @return
     */
    @Select("select file_id,file_url from file where file_id = #{i}")
    FileVO getFileUrlByFileid(@Param("i") Integer i);

}
/*file_id,file_name,*/
//    and create_time >= #{typeDownloadFileDTO.createTime} and over_time <= #{typeDownloadFileDTO.overTime}